import os
from rest_framework.decorators import api_view,throttle_classes
from rest_framework.throttling import BaseThrottle
from django.http import FileResponse
from student.models import StudentData

@api_view(["GET"])
# @throttle_classes([BaseThrottle])
def output(request):
    path = StudentData.objects.output_excel()
    response = FileResponse(open(path, 'rb'))
    response['content_type'] = "application/octet-stream"
    response['Content-Disposition'] = 'attachment; filename=' + os.path.basename(path)
    return response